package siac.com.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "FacStatus")
@NamedQueries({
		@NamedQuery(name = "FacStatusLote.findAll", query = "SELECT e FROM FacStatusLote e"),
		@NamedQuery(name = "FacStatusLote.findById", query = "SELECT e FROM FacStatusLote e WHERE e.id = :idTabela"),
		@NamedQuery(name = "FacStatusLote.findByCode", query = "SELECT e FROM FacStatusLote e WHERE e.code = :code"),
		@NamedQuery(name = "FacStatusLote.findByName", query = "SELECT e FROM FacStatusLote e WHERE e.pais = :name") })
public class FacStatus implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue (strategy = GenerationType.AUTO)
	private Long id;
	@org.hibernate.annotations.NaturalId
	@Basic(optional = false)
	@Column(nullable = false, length = 3)
	private String code;
	@Basic(optional = false)
	@Column(nullable = false, length = 50)
	private String status;
	@Temporal(TemporalType.TIMESTAMP)
	private Date dataRegisto;
	private Long operadorRegisto;
	@Temporal(TemporalType.TIMESTAMP)
	private Date dataAlteracao;
	private Long operadorAlteracao;

	public FacStatus() {
	}

	@PrePersist
	public void preRegisto() {
		this.setDataRegisto(new Date());
	}

	@PrePersist
	@PreUpdate
	public void preAlteracao() {
		this.setDataAlteracao(new Date());
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Date getDataRegisto() {
		return dataRegisto;
	}

	public void setDataRegisto(Date dataRegisto) {
		this.dataRegisto = dataRegisto;
	}

	public Long getOperadorRegisto() {
		return operadorRegisto;
	}

	public void setOperadorRegisto(Long operadorRegisto) {
		this.operadorRegisto = operadorRegisto;
	}

	public Date getDataAlteracao() {
		return dataAlteracao;
	}

	public void setDataAlteracao(Date dataAlteracao) {
		this.dataAlteracao = dataAlteracao;
	}

	public Long getOperadorAlteracao() {
		return operadorAlteracao;
	}

	public void setOperadorAlteracao(Long operadorAlteracao) {
		this.operadorAlteracao = operadorAlteracao;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FacStatus other = (FacStatus) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return code + " - " + status;
	}
	
	
	
	
	
}